package com.douyang.controller;

import com.douyang.dto.GetVideoListByLikesDTO;
import com.douyang.dto.VideoInfoListDTO;
import com.douyang.base.model.PageResult;
import com.douyang.base.model.Result;
import com.douyang.service.VideoBaseInfoService;
import com.douyang.vo.VideoBaseInfoListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoma
 * @since 2025-02-27
 */
@RestController
@RequestMapping("/video/videoBaseInfo")
public class VideoBaseInfoController {

    @Autowired
    private VideoBaseInfoService videoBaseInfoService;

    @PostMapping("/getVideoInfoList")
    public Result<PageResult<VideoBaseInfoListVO>> getVideoInfoList(@RequestBody VideoInfoListDTO videoInfoListDTO) {
        return Result.success(videoBaseInfoService.getVideoInfoList(videoInfoListDTO));
    }

    @PostMapping("/getVideoInfoListByLikes")
    public Result<PageResult<VideoBaseInfoListVO>> getVideoInfoListByLikes(@RequestBody GetVideoListByLikesDTO getVideoListByLikesDTO) {
        return Result.success(videoBaseInfoService.getVideoInfoListByLikes(getVideoListByLikesDTO));
    }

    @PostMapping("/uploadImage")
    public Result<String> uploadImage(@RequestParam("file") MultipartFile file) {
        return Result.success(videoBaseInfoService.uploadImage(file));
    }

    @DeleteMapping("/updateVideoShow/{id}/{deleted}")
    public Result<String> removeVideo(@PathVariable("id") Long id,@PathVariable("deleted") Boolean deleted) {
        videoBaseInfoService.removeVideo(id,deleted);
        return Result.success("ok");
    }

}
